package com.jiayang.hhotel.presenter;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.bean.InfoModel;
import com.jiayang.hhotel.net.Api;
import com.jiayang.hhotel.ui.RegistActivity;
import com.jiayang.hhotel.util.LogUtil;
import com.jiayang.hhotel.util.ToastUtil;

import cn.droidlover.xdroidmvp.mvp.XPresent;
import cn.droidlover.xdroidmvp.net.ApiSubscriber;
import cn.droidlover.xdroidmvp.net.NetError;
import cn.droidlover.xdroidmvp.net.XApi;

/**
 * Created by Administrator on 2017/5/16 0016.
 * 注册页面逻辑类
 */

public class PRegister extends XPresent<RegistActivity> {

    public  void getIdenCode(String phoneNum){
        Api.getUserService().getcode(phoneNum)
                .compose(XApi.<InfoModel>getApiTransformer())
                .compose(XApi.<InfoModel>getScheduler())
                .compose(getV().<InfoModel>bindToLifecycle())
                .subscribe(new ApiSubscriber<InfoModel>() {
                    @Override
                    protected void onFail(NetError error) {
                        ToastUtil.Toast(getV().getString(R.string.net_error),getV());
                    }

                    @Override
                    public void onNext(InfoModel Results) {
                        LogUtil.showLog(Results.toString());
                        getV().setIden_code(Results);
                    }
                });
    }

}
